VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmFindBatch 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Batch and Lot number"
   ClientHeight    =   5130
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5055
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmFindBatch.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5130
   ScaleWidth      =   5055
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame1 
      Height          =   4545
      Left            =   60
      TabIndex        =   3
      Top             =   60
      Width           =   4935
      Begin ITGControls.ITGTextBox txtRetPur 
         Height          =   285
         Left            =   1980
         TabIndex        =   10
         Top             =   2520
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Returns"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin MSComctlLib.ListView lvwList 
         Height          =   4155
         Left            =   120
         TabIndex        =   0
         Top             =   240
         Width           =   1500
         _ExtentX        =   2646
         _ExtentY        =   7329
         View            =   3
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         HotTracking     =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   0
         NumItems        =   1
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Reference No."
            Object.Width           =   2540
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtSMCode 
         Height          =   285
         Left            =   1785
         TabIndex        =   5
         Top             =   1005
         Width           =   2970
         _ExtentX        =   5027
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Remarks"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1910
      End
      Begin ITGControls.ITGDateBox dtbDate 
         Height          =   285
         Left            =   2790
         TabIndex        =   6
         Tag             =   "Order Date"
         Top             =   1365
         Width           =   1380
         _ExtentX        =   2434
         _ExtentY        =   503
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   ""
         SendKeysTab     =   -1  'True
         Mandatory       =   -1  'True
         DatePicker      =   0   'False
      End
      Begin ITGControls.ITGLabel ITGLabel4 
         Height          =   285
         Left            =   1815
         TabIndex        =   7
         Top             =   1365
         Width           =   915
         _ExtentX        =   1614
         _ExtentY        =   503
         Caption         =   "Expiry"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtPurchase 
         Height          =   285
         Left            =   1980
         TabIndex        =   9
         Top             =   2160
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Purchase"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin ITGControls.ITGTextBox txtSales 
         Height          =   285
         Left            =   1980
         TabIndex        =   11
         Top             =   2880
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Sales"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin ITGControls.ITGTextBox txtRetSales 
         Height          =   285
         Left            =   1980
         TabIndex        =   12
         Top             =   3240
         Width           =   2370
         _ExtentX        =   3969
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Ret. Sales"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1310
      End
      Begin ITGControls.ITGTextBox txtDamaged 
         Height          =   285
         Left            =   1980
         TabIndex        =   13
         Top             =   3600
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Damaged"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin ITGControls.ITGTextBox txtBalance 
         Height          =   285
         Left            =   1980
         TabIndex        =   14
         Top             =   3960
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Balance"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin ITGControls.ITGTextBox txtTPCGross 
         Height          =   285
         Left            =   1980
         TabIndex        =   15
         Top             =   2160
         Visible         =   0   'False
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "TPC Gross"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin ITGControls.ITGTextBox txtTPCBalance 
         Height          =   285
         Left            =   1980
         TabIndex        =   16
         Top             =   2520
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "TPC Balance"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin VB.Line Line1 
         X1              =   2400
         X2              =   4800
         Y1              =   1980
         Y2              =   1980
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Details"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   195
         Index           =   2
         Left            =   1740
         TabIndex        =   8
         Top             =   1875
         Width           =   585
      End
      Begin VB.Label lblItem 
         Alignment       =   2  'Center
         Caption         =   "Item"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   555
         Left            =   1800
         TabIndex        =   4
         Top             =   300
         Width           =   2970
      End
   End
   Begin ITGControls.ITGCommandButton cmdCancel 
      Height          =   345
      Left            =   3795
      TabIndex        =   2
      Top             =   4695
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Cancel"
   End
   Begin ITGControls.ITGCommandButton cmdOK 
      Height          =   345
      Left            =   2535
      TabIndex        =   1
      Top             =   4695
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&OK"
   End
End
Attribute VB_Name = "frmFindBatch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

Enum eBatchPick
    Batch_Lot
End Enum

Public mBatchPick As eBatchPick
Public mBatchID As String


Private connList As New ADODB.Connection

Private Sub cmdCancel_Click()
    Unload Me
    Set frmFindBatch = Nothing
End Sub

Private Sub cmdOK_Click()
    If lvwList.ListItems.Count = 0 Then
        Unload Me
        Exit Sub
    End If
    Unload Me
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyEscape Then
        Unload Me
        Set frmFindBatch = Nothing
    End If
End Sub

Private Sub Form_Load()
Dim rsSIList As New Recordset

    'Item Code = "RepName"
    Select Case mBatchPick
        Case Batch_Lot
            sSQL = "SELECT cBatchID FROM BATCH WHERE cItemNo = '" & Trim(RepName) & "'"
            Me.Caption = "Batch and Lot No"
    End Select
    
    OpenNewConnection connList
    
    rsSIList.Open sSQL, connList, adOpenForwardOnly, adLockReadOnly
    
    lvwList.ListItems.Clear
    
    Do Until rsSIList.EOF
        Set itmX = lvwList.ListItems.Add(, , Trim(rsSIList!cBatchID))
        rsSIList.MoveNext
    Loop
    
    rsSIList.Close
    Set rsSIList = Nothing
    
    lblItem = RepName & " - " & GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(RepName) & "'")
    
    If lvwList.ListItems.Count <> 0 Then lvwList_ItemClick lvwList.ListItems(lvwList.SelectedItem.Index)

End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set connList = Nothing
    RepName = ""
    cString = ""
End Sub

Private Sub lvwList_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    lvwList.Sorted = True
    lvwList.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub lvwList_ItemClick(ByVal Item As MSComctlLib.ListItem)
    If lvwList.ListItems.Count = 0 Then Exit Sub
    mBatchID = Trim(lvwList.SelectedItem)
    ListInvDetail (Trim(lvwList.SelectedItem))
End Sub

'Show invoice details
Sub ListInvDetail(InvNo As String)
On Error Resume Next
Dim rsList As New Recordset

    Select Case mBatchPick
        Case Batch_Lot
            sSQL = "SELECT A.*, (A.nPurchase - A.nRetPur + A.nRetSales - A.nSales) AS nBalance FROM V_ProductBatch_Module A " & _
                    "WHERE A.cBatchID = '" & Trim(lvwList.SelectedItem) & "' AND A.cCompanyID = '" & COID & "'"
    End Select
    
    OpenNewConnection connList

    rsList.Open sSQL, connList, adOpenForwardOnly, adLockReadOnly
    
    With rsList
'        txtSMCode = Trim(!cSMan) & ""
'        dtbDate.Text = Format(!dDate, "MM/dd/yyyy")
'        mdDate = Format(!dDate, "MM/dd/yyyy")
        txtPurchase = !nPurchase
        txtSales = !nSales
'        txtPayment = !nPaid
'        txtDebit = !nDebit
'        txtCredit = !nCredit
'        txtBalance = !nBalance
'        mnBalance = !nBalance
    End With
    
    If mBatchPick = Batch_Lot Then
'        txtGross.Visible = False
'        txtReturns.Visible = False
'        txtPayment.Visible = False
'        txtDebit.Visible = False
'        txtCredit.Visible = False
'        txtBalance.Visible = False
'        txtTPCGross.Visible = True
'        txtTPCGross.Label = "TPC Gross"
'        txtTPCBalance.Label = "TPC Balance"
'        txtTPCGross = rsList!nTPCGross
'        txtTPCBalance = rsList!nTPCBalance
'        mnTPCBalance = rsList!nTPCBalance
    End If
    
    rsList.Close
    Set rsList = Nothing

End Sub

Private Sub lvwList_KeyPress(KeyAscii As Integer)
    If lvwList.ListItems.Count = 0 Then Exit Sub
    If KeyAscii = 13 Then
        lvwList_ItemClick lvwList.ListItems(lvwList.SelectedItem.Index)
        SendKeys "{Tab}"
    End If
End Sub
